﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;

namespace MyResult
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlDocument xmlDocument = new XmlDocument();
            string filePath = Environment.CurrentDirectory;
            filePath = filePath.Substring(0, filePath.IndexOf("MyResult"));
            string outPutPath = filePath + "TestResult.txt";
            filePath += "TestResults\\";
            DirectoryInfo dir = new DirectoryInfo(filePath);
            filePath = dir.GetFiles()[0].FullName;
            xmlDocument.Load(filePath);


            XmlNode node = xmlDocument.ChildNodes[1];

            XmlNode node1 = node.ChildNodes[2];
            XmlNode node2 = node1.ChildNodes[0];
          //  string aaa = node1.InnerXml.ToString();
            string total = node2.Attributes["total"].InnerText;
            string executed = node2.Attributes["executed"].InnerText;
            string passed = node2.Attributes["passed"].InnerText;
            StreamWriter writer = new StreamWriter(new FileStream(outPutPath, FileMode.Create, FileAccess.Write));
            writer.Write(string.Format("total={0} executed={1} passed={2}", total, executed, passed));
            writer.Close();
        }
    }
}
